
$(function () {
    $("#jqGrid").jqGrid({
        url: '../workItemSub/list',
        datatype: "json",
        colModel: [
			{ label: 'id', name: 'id', width: 50, key: true },
			{ label: '作业项ID', name: 'itemId',index:'item_id', width: 80 },
			{ label: '名称', name: 'subName',index:'sub_name', width: 80 },
			{ label: '数据源key', name: 'dbKeyFrom',index:'db_key_from', width: 80 },
			{ label: '子sql', name: 'subSql',index:'sub_sql', width: 80 },
			{ label: '排序号', name: 'orderNum',index:'order_num', width: 80 },
			{ label: 'createTime', name: 'createTime',index:'create_time', width: 80 },
			{ label: 'updateTime', name: 'updateTime',index:'update_time', width: 80 },
			{ label: 'subType', name: 'subType',index:'sub_type', width: 80 },
			{ label: '缓存名称', name: 'cacheName',index:'cache_name', width: 80 },
			{ label: '缓存Key对应字段', name: 'cacheKeyField',index:'cache_key_field', width: 80 },
			{ label: '缓存获取的字段,多个字段用英文逗号分隔', name: 'cacheGetFields',index:'cache_get_fields', width: 80 }
        ],
		viewrecords: true,
        height: 800,
        rowNum: 20,
		rowList : [20,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
			root: "page.data",
			page: "page.pageNo",
			total: "page.pageCount",
			records: "page.count"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	//$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		isShowCond:false,
        btnText:'查询',
        qryForm:{
        }
	},
	methods: {
		reset: function(){

        },
        query: function () {
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{
                },
                page:1
            }).trigger("reloadGrid");
        },
        toggle:function(){
            this.isShowCond = !this.isShowCond;

            if(this.isShowCond==true){
                this.btnText = "隐藏"
            }else if(this.isShowCond==false){
                this.btnText = "查询"
            }

        },
		update: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			
			location.href = "workItemSub_add.html?id="+id;
		},
		del: function (event) {
			var ids = getSelectedRows();
			if(ids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: "../workItemSub/delete",
				    data: JSON.stringify(ids),
				    success: function(outJson){
						if(outJson.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(outJson.msg);
						}
					}
				});
			});
		}
	}
});
